﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：YS_LH_LAIHANLCJL实体层次
//********************************************************************************//
#region Entity
namespace Entity
{
    using System;
    using System.Xml;
    [Serializable()]
    public class YS_LH_LAIHANLCJL
    {

        private decimal m_dec_id;
        /// <summary>
        /// 主键
        /// </summary>
        public decimal ID { get { return m_dec_id; } set { m_dec_id = value; } }

        private string m_str_s_laihanbh;
        /// <summary>
        /// 来函编号
        /// </summary>
        public string S_LAIHANBH { get { return m_str_s_laihanbh; } set { m_str_s_laihanbh = value; } }

        private decimal? m_dec_i_laihanlx;
        /// <summary>
        /// 来函类型
        /// </summary>
        public decimal? I_LAIHANLX { get { return m_dec_i_laihanlx; } set { m_dec_i_laihanlx = value; } }

        private string m_str_s_liuchengmc;
        /// <summary>
        /// 流程名称
        /// </summary>
        public string S_LIUCHENGMC { get { return m_str_s_liuchengmc; } set { m_str_s_liuchengmc = value; } }

        private decimal? m_dec_i_liuchengbh;
        /// <summary>
        /// 流程编号
        /// </summary>
        public decimal? I_LIUCHENGBH { get { return m_dec_i_liuchengbh; } set { m_dec_i_liuchengbh = value; } }

        private DateTime? m_DT_d_startdate;
        /// <summary>
        /// 进入本流程时间
        /// </summary>
        public DateTime? D_STARTDATE { get { return m_DT_d_startdate; } set { m_DT_d_startdate = value; } }

        private DateTime? m_DT_d_enddate;
        /// <summary>
        /// 完成本流程时间
        /// </summary>
        public DateTime? D_ENDDATE { get { return m_DT_d_enddate; } set { m_DT_d_enddate = value; } }

        private decimal? m_dec_i_caozuor;
        /// <summary>
        /// 操作人
        /// </summary>
        public decimal? I_CAOZUOR { get { return m_dec_i_caozuor; } set { m_dec_i_caozuor = value; } }

        private DateTime m_DT_d_caozuorq;
        /// <summary>
        /// 操作时间
        /// </summary>
        public DateTime D_CAOZUORQ { get { return m_DT_d_caozuorq; } set { m_DT_d_caozuorq = value; } }

        private decimal m_dec_i_jlzt;
        /// <summary>
        /// 
        /// </summary>
        public decimal I_JLZT { get { return m_dec_i_jlzt; } set { m_dec_i_jlzt = value; } }

        private string m_str_s_caozuorqm;
        /// <summary>
        /// 操作人电子签名图片路径
        /// </summary>
        public string S_CAOZUORQM { get { return m_str_s_caozuorqm; } set { m_str_s_caozuorqm = value; } }
        public YS_LH_LAIHANLCJL()
        {
        }
    }
}
#endregion
#region EntityProcess
namespace BLL.Access
{
    using System;
    using System.Data;
    //using System.Data.OracleClient;
    using Entity;
    using System.Configuration;
    using System.Data.Common;
    using Platform.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    using Oracle.DataAccess;
    public class YS_LH_LAIHANLCJLProcess
    {
        #region Field
        protected string conn;
        #endregion
        #region Construction
        public YS_LH_LAIHANLCJLProcess() { conn = Platform.Configuration.ConfigHelper.PlatformConnString; }
        #endregion
        #region public

        /// <summary>
        /// 根据YS_LH_LAIHANLCJL实体添加或者修改YS_LH_LAIHANLCJL信息
        /// </summary>
        public bool InsertOrUpdate(YS_LH_LAIHANLCJL YS_LH_LAIHANLCJL, OracleTransaction Transaction)
        {
            if (YS_LH_LAIHANLCJL.ID == 0)
            {
                InsertYS_LH_LAIHANLCJL(YS_LH_LAIHANLCJL, Transaction);
            }
            else
            {
                UpdateYS_LH_LAIHANLCJL(YS_LH_LAIHANLCJL, Transaction);
            }
            return YS_LH_LAIHANLCJL.ID == 0 ? false : true;
        }

        /// <summary>
        /// 根据YS_LH_LAIHANLCJL实体添加或修改YS_LH_LAIHANLCJL信息
        /// </summary>
        public bool InsertOrUpdate(YS_LH_LAIHANLCJL YS_LH_LAIHANLCJL)
        {
            return InsertOrUpdate(YS_LH_LAIHANLCJL, null);
        }



        /// <summary>
        /// 根据YS_LH_LAIHANLCJL主键删除YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteYS_LH_LAIHANLCJL(decimal ID, OracleTransaction Transaction)
        {
            string spName = "CS_DelYS_LH_LAIHANLCJL";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据YS_LH_LAIHANLCJL主键删除YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteYS_LH_LAIHANLCJL(decimal ID)
        {
            return DeleteYS_LH_LAIHANLCJL(ID, null);
        }

        /// <summary>
        /// 根据条件删除YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteYS_LH_LAIHANLCJLsDynamic(string WhereClause, OracleTransaction Transaction)
        {
            string spName = "CS_DelYS_LH_LAIHANLCJLsDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据条件删除YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteYS_LH_LAIHANLCJLsDynamic(string WhereClause)
        {
            return DeleteYS_LH_LAIHANLCJLsDynamic(WhereClause, null);
        }

        /// <summary>
        /// 根据YS_LH_LAIHANLCJL主键选择YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_LH_LAIHANLCJL信息</returns>
        public YS_LH_LAIHANLCJL SelectYS_LH_LAIHANLCJL(decimal ID, OracleTransaction Transaction)
        {
            string spName = "CS_SelYS_LH_LAIHANLCJL";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                YS_LH_LAIHANLCJL YS_LH_LAIHANLCJL = PopulateYS_LH_LAIHANLCJL(rd);
                rd.Close();
                return YS_LH_LAIHANLCJL;
            }
            else
                return null;
        }

        /// <summary>
        /// 根据YS_LH_LAIHANLCJL主键选择YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <returns>YS_LH_LAIHANLCJL信息</returns>
        public YS_LH_LAIHANLCJL SelectYS_LH_LAIHANLCJL(decimal ID)
        {
            return SelectYS_LH_LAIHANLCJL(ID, null);
        }

        /// <summary>
        /// 选择所有YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有YS_LH_LAIHANLCJL信息</returns>
        public DataTable SelectYS_LH_LAIHANLCJLsAll(OracleTransaction Transaction)
        {
            string spName = "CS_SelYS_LH_LAIHANLCJLsAll";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }

        /// <summary>
        /// 选择所有YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <returns>所有YS_LH_LAIHANLCJL信息</returns>
        public DataTable SelectYS_LH_LAIHANLCJLsAll()
        {
            return SelectYS_LH_LAIHANLCJLsAll(null);
        }

        /// <summary>
        /// 根据条件选择YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_LH_LAIHANLCJL信息</returns>
        public DataTable SelectYS_LH_LAIHANLCJLsDynamic(string WhereClause, string OrderByExpression, OracleTransaction Transaction)
        {
            string spName = "CS_SelYS_LH_LAIHANLCJLsDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>YS_LH_LAIHANLCJL信息</returns>
        public DataTable SelectYS_LH_LAIHANLCJLsDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectYS_LH_LAIHANLCJLsDynamic(WhereClause, OrderByExpression, null);
        }



        /// <summary>
        /// 根据条件选择YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_LH_LAIHANLCJL信息</returns>
        public DataTable SelectYS_LH_LAIHANLCJLsDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize, OracleTransaction Transaction)
        {
            string spName = "CS_SelYS_LH_LAIHANLCJLsDynPaged";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择YS_LH_LAIHANLCJL信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>YS_LH_LAIHANLCJL信息</returns>
        public DataTable SelectYS_LH_LAIHANLCJLsDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize)
        {
            return SelectYS_LH_LAIHANLCJLsDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///根据条件更新YS_LH_LAIHANLCJL字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateYS_LH_LAIHANLCJLsDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            int result = 0;
            if (UpdateValue == "" || WhereClause == "")
            {
                return 0;
            }
            string spName = "CS_UpdYS_LH_LAIHANLCJLDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///根据条件更新YS_LH_LAIHANLCJL字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateYS_LH_LAIHANLCJLsDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateYS_LH_LAIHANLCJLsDynamic(UpdateValue, WhereClause, null);
        }


        #endregion
        #region Private

        private int InsertYS_LH_LAIHANLCJL(YS_LH_LAIHANLCJL YS_LH_LAIHANLCJL, OracleTransaction Transaction)
        {
            string spName = "CS_InsYS_LH_LAIHANLCJL";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = YS_LH_LAIHANLCJL.S_LAIHANBH;
            storedParams[1].Value = YS_LH_LAIHANLCJL.I_LAIHANLX;
            storedParams[2].Value = YS_LH_LAIHANLCJL.S_LIUCHENGMC;
            storedParams[3].Value = YS_LH_LAIHANLCJL.I_LIUCHENGBH;
            storedParams[4].Value = YS_LH_LAIHANLCJL.D_STARTDATE;
            storedParams[5].Value = YS_LH_LAIHANLCJL.D_ENDDATE;
            storedParams[6].Value = YS_LH_LAIHANLCJL.I_CAOZUOR;
            storedParams[7].Value = YS_LH_LAIHANLCJL.D_CAOZUORQ;
            storedParams[8].Value = YS_LH_LAIHANLCJL.I_JLZT;
            storedParams[9].Value = YS_LH_LAIHANLCJL.S_CAOZUORQM;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            YS_LH_LAIHANLCJL.ID = Convert.ToInt32(storedParams[10].Value);
            return result;
        }
        private bool UpdateYS_LH_LAIHANLCJL(YS_LH_LAIHANLCJL YS_LH_LAIHANLCJL, OracleTransaction Transaction)
        {
            string spName = "CS_UpdYS_LH_LAIHANLCJL";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = YS_LH_LAIHANLCJL.S_LAIHANBH;
            storedParams[1].Value = YS_LH_LAIHANLCJL.I_LAIHANLX;
            storedParams[2].Value = YS_LH_LAIHANLCJL.S_LIUCHENGMC;
            storedParams[3].Value = YS_LH_LAIHANLCJL.I_LIUCHENGBH;
            storedParams[4].Value = YS_LH_LAIHANLCJL.D_STARTDATE;
            storedParams[5].Value = YS_LH_LAIHANLCJL.D_ENDDATE;
            storedParams[6].Value = YS_LH_LAIHANLCJL.I_CAOZUOR;
            storedParams[7].Value = YS_LH_LAIHANLCJL.D_CAOZUORQ;
            storedParams[8].Value = YS_LH_LAIHANLCJL.I_JLZT;
            storedParams[9].Value = YS_LH_LAIHANLCJL.S_CAOZUORQM;
            storedParams[10].Value = YS_LH_LAIHANLCJL.ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private YS_LH_LAIHANLCJL PopulateYS_LH_LAIHANLCJL(IDataReader dr)
        {
            YS_LH_LAIHANLCJL YS_LH_LAIHANLCJL = new YS_LH_LAIHANLCJL();
            YS_LH_LAIHANLCJL.ID = dr["ID"] == DBNull.Value ? (decimal)0 : (decimal)dr["ID"];
            YS_LH_LAIHANLCJL.S_LAIHANBH = dr["S_LAIHANBH"] == DBNull.Value ? null : (string)dr["S_LAIHANBH"];
            YS_LH_LAIHANLCJL.I_LAIHANLX = dr["I_LAIHANLX"] == DBNull.Value ? null : (decimal?)dr["I_LAIHANLX"];
            YS_LH_LAIHANLCJL.S_LIUCHENGMC = dr["S_LIUCHENGMC"] == DBNull.Value ? null : (string)dr["S_LIUCHENGMC"];
            YS_LH_LAIHANLCJL.I_LIUCHENGBH = dr["I_LIUCHENGBH"] == DBNull.Value ? null : (decimal?)dr["I_LIUCHENGBH"];
            YS_LH_LAIHANLCJL.D_STARTDATE = dr["D_STARTDATE"] == DBNull.Value ? null : (DateTime?)dr["D_STARTDATE"];
            YS_LH_LAIHANLCJL.D_ENDDATE = dr["D_ENDDATE"] == DBNull.Value ? null : (DateTime?)dr["D_ENDDATE"];
            YS_LH_LAIHANLCJL.I_CAOZUOR = dr["I_CAOZUOR"] == DBNull.Value ? null : (decimal?)dr["I_CAOZUOR"];
            YS_LH_LAIHANLCJL.D_CAOZUORQ = dr["D_CAOZUORQ"] == DBNull.Value ? Convert.ToDateTime("1900-1-1") : (DateTime)dr["D_CAOZUORQ"];
            YS_LH_LAIHANLCJL.I_JLZT = dr["I_JLZT"] == DBNull.Value ? (decimal)0 : (decimal)dr["I_JLZT"];
            YS_LH_LAIHANLCJL.S_CAOZUORQM = dr["S_CAOZUORQM"] == DBNull.Value ? null : (string)dr["S_CAOZUORQM"];
            return YS_LH_LAIHANLCJL;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
            }
        }
        #endregion
    }
}
#endregion